package com.itheima.Day11.ZuoYe.ZuoYe3;

import java.io.*;

public class test {
    public static void main(String[] args) {
        try(DataInputStream dos = new DataInputStream(new BufferedInputStream(new FileInputStream("D:\\javajc_ws\\javaEE\\src\\com\\itheima\\Day11\\ZuoYe\\ZuoYe3\\qes.txt")));){
            String x;
            while ((x = dos.readLine()) != null){
                if(x.contains("+")){
                    String[] y = x.split("\\+");
                    int res =0;
                    for (int i = 0; i < y.length; i++) {
                        res += Integer.parseInt(y[i]);
                    }
                    System.out.println(x+"="+res);
                }else if(
                        x.contains("-")
                ){
                    String[] y = x.split("-");
                    int res =0;
                        res = Integer.parseInt(y[0])-Integer.parseInt(y[1]);

                    System.out.println(x+"="+res);
                }else if(
                        x.contains("*")
                ){
                    String[] y = x.split("\\*");
                    int res =1;
                    for (int i = 0; i < y.length; i++) {
                        res *= Integer.parseInt(y[i]);
                    }
                    System.out.println(x+"="+res);
                }else if(x.contains("/")){
                    String[] y = x.split("/");
                    int res =1;
                    if(Integer.parseInt(y[1])!=0){
                        res = Integer.parseInt(y[0])/Integer.parseInt(y[1]);
                        System.out.println(x+"="+res);
                        }else{
                        System.out.println("除数不能为0");
                        }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
